local jianying = fk.CreateSkill {
  name = "lvshi__jianying",
}

Fk:loadTranslationTable{
  ["lvshi__jianying"] = "渐营",
  ["@lvshi__jianying-turn"] = "渐营",
  [":lvshi__jianying"] = "当你使用牌时，若此牌点数大于或小于你于此回合使用过的所有牌，则你摸一张牌。",

  ["$lvshi__jianying1"] = "缓耗蚕食，乃万安之法。",
  ["$lvshi__jianying2"] = "图南宜缓，需从长计议。",
}

jianying:addEffect(fk.CardUsing, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(jianying.name) and target == player and #player:getTableMark("@lvshi__jianying-turn") > 0 and data.card.number > 0 then
      return data.card.number < player:getTableMark("@lvshi__jianying-turn")[1] or data.card.number > player:getTableMark("@lvshi__jianying-turn")[2]
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    if data.card.number < player:getTableMark("@lvshi__jianying-turn")[1] then
      player.room:setPlayerMark(player, "@lvshi__jianying-turn", {data.card.number, player:getTableMark("@lvshi__jianying-turn")[2]})
    end
    if data.card.number > player:getTableMark("@lvshi__jianying-turn")[2] then
      player.room:setPlayerMark(player, "@lvshi__jianying-turn", {player:getTableMark("@lvshi__jianying-turn")[1], data.card.number})
    end
    player:drawCards(1, jianying.name)
  end,

  refresh_events = {fk.AfterCardUseDeclared},
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(jianying.name) and data.card.number > 0 and #player:getTableMark("@lvshi__jianying-turn") == 0
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@lvshi__jianying-turn", {data.card.number, data.card.number})
  end,
})


return jianying